import 'package:flutter/material.dart';

import 'package:junyeyishu/utils/utils.dart';
import 'package:junyeyishu/widgets/QGWidget.dart';

import 'QGMineOrderCell.dart';

class QGMineTradeOrderCell extends QGMineOrderCell {
  QGMineTradeOrderCell({super.key, super.data});
  @override
  State<QGMineOrderCell> createState() => _QGMineTradeOrderCellState();
}

class _QGMineTradeOrderCellState extends QGMineOrderCellState {
  buildState() {
    Widget child = Container();

    // "已买入", "待支付", "进行中", "已取消", "已售出"

    switch (widget.data?["status"]) {
      case 0:
        child = buildSuccess(title: "转入成功");
        break;
      case 1:
        child = buildWaiting();
        break;
      case 2:
        child = buildSuccess(title: "发放中");
        break;
      case 3:
        child = buildCancel();
        break;
      case 4:
        child = buildSuccess(title: "藏品已售出，结算成功");
        break;
      default:
        break;
    }

    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Container(
            padding: EdgeInsets.symmetric(horizontal: 7.rpx, vertical: 3.rpx),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(5.rpx),
              color: Color(0xFFF8F8F6),
            ),
            child: child),
        QGImage(asset: "mine_info_arrow"),
      ],
    );
  }

  buildSuccess({title}) {
    return Row(
      children: [
        QGImage(asset: "mine_order_success"),
        SizedBox(width: 10.rpx),
        Text(
          title,
          style: TextStyle(
              color: const Color(0xFF00AF54),
              fontSize: 11.rpx,
              fontWeight: FontWeight.normal),
        ),
      ],
    );
  }

  buildCancel() {
    return Row(
      children: [
        QGImage(asset: "mine_order_cancel"),
        SizedBox(width: 10.rpx),
        Text(
          '订单已取消',
          style: TextStyle(
              color: const Color(0xff969696),
              fontSize: 11.rpx,
              fontWeight: FontWeight.normal),
        ),
      ],
    );
  }

  buildWaiting() {
    return Row(
      children: [
        QGImage(asset: "mine_order_waiting"),
        SizedBox(width: 10.rpx),
        Text(
          '等待付款',
          style: TextStyle(
              color: const Color(0xffE61212),
              fontSize: 11.rpx,
              fontWeight: FontWeight.normal),
        ),
        // SizedBox(width: 8.rpx),
        // Text(
        //   '00:05:00',
        //   style: TextStyle(
        //       color: const Color(0xffffffff),
        //       fontSize: 12.rpx,
        //       fontWeight: FontWeight.normal),
        // ),
      ],
    );
  }
}
